#include "pcmspec.h"

void PCMSpec::calFrameSize()
{
    int channelNums = av_get_channel_layout_nb_channels(_channelLayout);
    int formatBytes = av_get_bytes_per_sample(_format);
    _frameSize = _sampleRate * channelNums * formatBytes;
}

PCMSpec::PCMSpec():
    PCMSpec(0,0,AV_SAMPLE_FMT_NONE)
{

}

PCMSpec::PCMSpec(int sampleRate, int channelLayout, AVSampleFormat format):
    _sampleRate(sampleRate),_channelLayout(channelLayout),_format(format)
{

    calFrameSize();

}

int PCMSpec::getSampleRate() const
{

    return _sampleRate;
}

int PCMSpec::getChannelLayout() const
{

    return _channelLayout;
}

int PCMSpec::getFormat() const
{

    return _format;
}

int PCMSpec::frameSize() const
{

    return _frameSize;
}

void PCMSpec::setSampleRate(int sampleRate)
{
    _sampleRate = sampleRate;
}

void PCMSpec::setChannelLayout(int channelLayout)
{
    _channelLayout = channelLayout;
}

void PCMSpec::setSampleFormat(AVSampleFormat format)
{
    _format = format;
}
